package com.glamour.hlcity.component.framework.registry;

import java.util.Collection;

import org.openide.util.Lookup;

import com.glamour.hlcity.component.framework.registry.impl.DefaultServiceRegistry;

/**
 * 服务注册
 * @author zhaoxing.liuzx
 *
 */
public abstract class ServiceRegistry {
	//默认服务注册实现类
	private  static ServiceRegistry DEFAULT_REGISTEY=new DefaultServiceRegistry();
	private  static Lookup lookup;
	
	public static void setDefault(ServiceRegistry registry){
		DEFAULT_REGISTEY=registry;
	}
	
	public static ServiceRegistry getDefault(){
		return DEFAULT_REGISTEY;
		
	}
	
	/**
	 * 新增服务
	 */
	public  <T> ServiceRegistry addService(T service){
		return this;
	}
	
	
	public static  Collection lookupAll(Class clazz) {
		return DEFAULT_REGISTEY.getLookup().lookupAll(clazz);
	}
	
	public static <T> T lookup(Class<T> clazz){
		return DEFAULT_REGISTEY.getLookup().lookup(clazz);
	}
	
	/**
	 * @return
	 */
	public Lookup getLookup(){
		return lookup;
	}
	
	public void setLookup(Lookup lookup){
		this.lookup=lookup;
	}
}
